<template>
	<view>
		<!-- 搜索栏 -->
		<z-search :data="searchVal" msg="搜索子订单号/快递单号" @onSearch="searchOrder"/>
		<!-- <view class="height-line"></view> -->
		<!-- tab栏 -->
		<z-tabs :data="tabs" @onChange="changeTab"></z-tabs>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				searchVal: '',
				detailsData: {},
				hasOrder: false,
				desc: '',
				tabs: ['订单详情', '退款记录'],
				tab: 0
			}
		},
		onLoad(opt) {
			if (opt.order) {
				this.searchVal = opt.order;
				this.searchOrder();
			}
		},
		methods: {
			changeTab(e){
				console.log(e.val)
				this.tab = e.val
			},
			searchOrder(e) {
				this.searchVal = e.val;
				if (!this.searchVal) {
					return false;
				}
				this.$request.request({
					url: 'order/list',
					method: 'GET',
					data: {
						searchValue: this.searchVal,
						searchType: 30
					}
				}).then(res => {
					if (res.data.list.total) {
						this.detailsData = res.data.list.data[0];
						this.hasOrder = true;
						this.getHistory();
					} else {
						//没有查询到订单
						this.hasOrder = false;
						this.desc = '没有查到订单数据'
					}
				})
			},
			getHistory() {

			}
		}
	}
</script>

<style lang="scss" scoped>

</style>
